<?php

	Class RegisterController {
	
		public function DoControll($aRegisterView, $aRegisterHandler) {
			
			$output = $aRegisterView->AddHeader();
			
			if($aRegisterView->PressedRegister() == true){
				if($aRegisterView->CheckInfo() === true){
					if($aRegisterHandler->AddUser($aRegisterView->GetUserName(), $aRegisterView->GetPassword(), $aRegisterView->GetEmail())){
						$output .= $aRegisterView->AddMessageUserCreated();
						return $output;
					}
					else {
						$output .= $aRegisterView->AddMessageError();
					}
				}
				else{
					$output .= $aRegisterView->CheckInfo();
				}
			}
			
			$output .= $aRegisterView->DoRegisterForm();
			

			return $output;
		}
	
	}
